package org.thotheolh.sweatkeeper.ui;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JToolBar;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

public class TemplatePanel extends JPanel {
	
	private JToolBar toolBar;
	private JButton newTemplateBtn;
	private JPanel contentPanel;
	private JTable table;
	private JButton editTemplateBtn;
	private JButton delBtn;

	/**
	 * Create the panel.
	 */
	public TemplatePanel() {
		setLayout(new BorderLayout(0, 0));
		
		toolBar = new JToolBar();
		this.add(toolBar, BorderLayout.NORTH);
		
		newTemplateBtn = new JButton("New Template");
		newTemplateBtn.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent evt) {
				TemplateSession session = new TemplateSession(TemplateSession.CREATE_MODE);
				session.setLocationRelativeTo(null);
				session.setVisible(true);
			}
		});
		toolBar.add(newTemplateBtn);
		
		editTemplateBtn = new JButton("Edit Template");
		editTemplateBtn.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent evt) {
				TemplateSession session = new TemplateSession(TemplateSession.EDIT_MODE);
				session.setLocationRelativeTo(null);
				session.setVisible(true);
			}
		});
		toolBar.add(editTemplateBtn);
		
		delBtn = new JButton("Delete Template");
		toolBar.add(delBtn);
		
		contentPanel = new JPanel();
		contentPanel.setLayout(new BorderLayout());
		//contentPanel.add();
		
		add(contentPanel, BorderLayout.CENTER);
		
		JScrollPane scrollPane = new JScrollPane();
		add(scrollPane, BorderLayout.CENTER);
		
		table = new JTable();
		table.setModel(new DefaultTableModel(
			new Object[][] {
			},
			new String[] {
				"TEMPLATE NAME", "DATE", "TYPE", "COMMENT"
			}
		));
		table.getColumnModel().getColumn(0).setPreferredWidth(147);
		table.getColumnModel().getColumn(1).setPreferredWidth(147);
		table.getColumnModel().getColumn(2).setPreferredWidth(147);
		scrollPane.setViewportView(table);


	}

}
